/**
 * @projectName gs_online
 * @package com.answer.wx.gateway.controller
 * @className com.answer.wx.gateway.controller.MessageController
 */
package com.answer.wx.gateway.controller;

import com.answer.wx.common.aop.ApiOptions;
import com.answer.wx.common.response.ResponseListEntity;
import com.answer.wx.dao.model.MessageImage;
import com.answer.wx.gateway.bean.MessageBean;
import com.answer.wx.gateway.bean.NewMessageBean;
import com.answer.wx.gateway.bean.ShopBean;
import com.answer.wx.gateway.service.MessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * MessageController
 * @description 消息添加类
 * @author answer_wx
 * @date 2022/8/8 17:22
 * @version 1.0
 */
@RestController
@RequestMapping("/message")
@Api(value = "消息管理", tags = {"消息管理"})
public class MessageController {
    @Autowired
    private MessageService messageService;

    @ApiOperation("添加消息")
    @PostMapping("/add/{userId}")
    @ApiOptions
    public MessageBean addMessage(@PathVariable Integer userId, @RequestBody MessageBean message) {
        message.setUserId(userId);
        return messageService.addMessage(message);
    }

    @ApiOperation("获取消息 分页和分类id")
    @GetMapping("/getAllMessageDetail/{categoryId}/{pageNumber}")
    @ApiOptions
    public ResponseListEntity<MessageBean> getMessageByCategoryId(@PathVariable Integer categoryId, @PathVariable Integer pageNumber) {
        return messageService.getMessageByCategoryId(categoryId, pageNumber);
    }

    @ApiOperation("获取消息 分页和userid")
    @PostMapping("/getAllMessageDetail/{pageNumber}")
    @ApiOptions
    public ResponseListEntity<MessageBean> getAttendMessageByUserId(Integer userId, @PathVariable Integer pageNumber) {
        return messageService.getAttendMessageByUserId(userId, pageNumber);
    }

    @ApiOperation("修改消息 userid")
    @PostMapping("/updateMessage")
    @ApiOptions
    public void updateMessageByUserId(Integer userId, Integer messageId, String message) {
        messageService.updateMessageByUserId(userId, messageId, message);
    }

    @ApiOperation("删除消息")
    @PostMapping("/deleteMessage")
    @ApiOptions
    public ResponseListEntity<MessageImage> deleteMessage(Integer userId, Integer messageId) {
        return messageService.deleteMessage(userId, messageId);
    }

    @ApiOperation("管理员添加消息")
    @PostMapping("/addNewMessageByAdmin")
    @ApiOptions
    public void addNewMessageByAdmin(Integer userId, Integer messageId, String message) {
        messageService.addNewMessageByAdmin(userId, messageId, message);
    }

    @ApiOperation("消息详情")
    @GetMapping("/getMessageDetailById/{messageId}")
    @ApiOptions
    public MessageBean getMessageDetailById(@PathVariable Integer messageId) {
        return messageService.getMessageDetailById(messageId);
    }

    @ApiOperation("分享消息")
    @GetMapping("/addShareCount/{messageId}")
    @ApiOptions
    public Integer addShareCount(@PathVariable Integer messageId) {
        return messageService.addShareCount(messageId);
    }

    @ApiOperation("商务信息详情")
    @GetMapping("/getShopMessageById/{id}")
    @ApiOptions
    public ShopBean getShopMessageById(@PathVariable Integer id) {
        return messageService.getShopMessageById(id);
    }

    @ApiOperation("我发布的")
    @GetMapping("/getMessageDetailByUserId/{userId}/{pageNumber}")
    @ApiOptions
    public ResponseListEntity<MessageBean> getMessageDetailByUserId(@PathVariable Integer userId, @PathVariable Integer pageNumber) {
        return messageService.getMessageDetailByUserId(userId, pageNumber);
    }

    @ApiOperation("我收藏的")
    @GetMapping("/getAllCollectionMessageByUserId/{userId}/{pageNumber}")
    @ApiOptions
    public ResponseListEntity<MessageBean> getAllCollectionMessageByUserId(@PathVariable Integer userId, @PathVariable Integer pageNumber) {
        return messageService.getAllCollectionMessageByUserId(userId, pageNumber);
    }

    @ApiOperation("我的新消息")
    @GetMapping("/getAllNewMessage/{userId}/{pageNumber}")
    @ApiOptions
    public ResponseListEntity<NewMessageBean> getAllNewMessage(@PathVariable Integer userId, @PathVariable Integer pageNumber) {
        return messageService.getAllNewMessage(userId, pageNumber);
    }
}